package com.wwewew;

import java.util.ArrayList;

public class StudentOperatorlmpl2 implements StudentOperator{

    @Override
    public void printAllInfo(ArrayList<Student> student) {
        System.out.println("---------全部学生信息如下---------");
        int count1=0;
        int count2=0;
        for (int i = 0; i < student.size(); i++) {
            Student s=student.get(i);
            System.out.println("第"+(i+1)+"位同学的信息是");
            System.out.println("姓名："+s.getName());
            System.out.println("性别："+s.getSex());
            System.out.println("成绩："+s.getScore());
            if(s.getSex()=='男'){
                count1++;
            }else {
                count2++;
            }
        }
        System.out.println("男生人数是"+count1+"女生人数是"+count2);
        System.out.println("全班人数是"+student.size());
    }

    @Override
    public void printAverageScore(ArrayList<Student> student) {
        double allScore=0;
        double max=student.get(0).getScore();
        double min=student.get(0).getScore();
        for (int i = 0; i < student.size(); i++) {
            Student s=student.get(i);
            if(s.getScore()>max)max=s.getScore();
            if(s.getScore()<min)min=s.getScore();
            allScore+=s.getScore();
        }
        System.out.println("平均分为："+(allScore-max-min)/(student.size()-2));
    }
}
